package com.cn.wanxi.servlet;

import com.cn.wanxi.model.ProductModel;
import com.cn.wanxi.model.ProductNavModel;
import com.cn.wanxi.service.ProductNavService;
import com.cn.wanxi.service.ProductService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/product")
public class ProductServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        CommonServlet.setCompanyAndNavData(req);

        ProductNavService productNavService = new ProductNavService();
        ProductNavModel[] productNavModels = productNavService.getProductNavModels();
        req.setAttribute("productNavModels", productNavModels);

        ProductService productService = new ProductService();
        ProductModel[] productModels = productService.getProductModels();
        req.setAttribute("productModels", productModels);
        req.getRequestDispatcher("/jsp/product.jsp").forward(req, resp);
    }
}
